package com.xgst.land.viewmodel

import com.hjq.http.EasyHttp
import com.hjq.http.listener.OnHttpListener
import com.xgst.land.base.BaseViewModel
import com.xgst.land.bean.PDListBean
import com.xgst.land.http.api.CheckListAPI
import java.lang.Exception

class InventoryListViewModel: BaseViewModel() {

    //sign: 检索条件(0:检索所有数据,1:检索核验中/未核验的数据)
    fun request(currentPage:String,sign:String,onSuccess:(MutableList<PDListBean.DataBean.PageListBean>)->Unit){
        EasyHttp.post(this)
            .api(CheckListAPI(currentPage,"20",sign))
            .request(object : OnHttpListener<PDListBean>{
                override fun onSucceed(result: PDListBean) {
                    onSuccess(result.data.pageList)
                }

                override fun onFail(e: Exception?) {

                }
            })
    }

    fun delete(pdId:String,onSuccess:()->Unit){
        /*viewModelScope.launch {
            val bean =  mApi.deletePD(pdId)
            when(bean){
                is ApiResult.Success -> onSuccess()
                is ApiResult.Error -> dismissProgress(bean.errorMessage)
            }
        }*/
    }
}